package com.pinkpig.mybatis.generator.plugins;

import java.util.List;

import org.mybatis.generator.api.IntrospectedTable;
import org.mybatis.generator.api.PluginAdapter;
import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType;
import org.mybatis.generator.api.dom.java.Interface;
import org.mybatis.generator.api.dom.java.TopLevelClass;

public class MapperAnnotationPlugin extends PluginAdapter {

    private final String ANNOTATION_MAPPER = "@Mapper";
    private final String ANNOTATION_MAPPER_JAVA_TYPE = "org.apache.ibatis.annotations.Mapper";
    
    @Override
    public boolean validate(List<String> warnings) {
        return true;
    }
    
    @Override
    public boolean clientGenerated(Interface interfaze, TopLevelClass topLevelClass,
            IntrospectedTable introspectedTable) {
        interfaze.addAnnotation(ANNOTATION_MAPPER);
        interfaze.addImportedType(new FullyQualifiedJavaType(ANNOTATION_MAPPER_JAVA_TYPE));
        return super.clientGenerated(interfaze, topLevelClass, introspectedTable);
    }

}
